package version2024.medium;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * @author sunhl
 * @Description: HJ17 坐标移动  数组, 字符串, 输入流
 * @Date: created in 2024/12/28 星期六 11:34
 * @Modified By:
 */
public class HJ17_CoordinateMovement {
    public static void main(String[] args) throws IOException {
        // 根据输入构建缓冲流
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));

        // 按;分割数组
        String[] in = bf.readLine().split(";");
        int x = 0;
        int y = 0;

        for (String s : in) {
            // 正则过滤非法字符, 数字限制1~2位
            if (!s.matches("[WASD][0-9]{1,2}")) {
                continue;
            }

            // 获取移动的坐标值
            int val = Integer.valueOf(s.substring(1));
            // 进行坐标的移动
            switch (s.substring(0, 1)) {
                case "W":
                    y += val;
                    break;
                case "S":
                    y -= val;
                    break;
                case "A":
                    x -= val;
                    break;
                case "D":
                    x += val;
                    break;
                default:
                    break;
            }
        }

        System.out.println(x + "," + y);

    }
}
